package friend

import (
	"api/common"
	"api/pb/friend"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteApplyLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeleteApplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteApplyLogic {
	return &DeleteApplyLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// DeleteApply 删除好友申请
func (l *DeleteApplyLogic) DeleteApply(req *types.ApplyInfoRequest) (resp *types.Empty, err error) {
	_, err = l.svcCtx.FriendRPC.UpdateApply(l.ctx, &friend.ApplyInfo{
		Id:     req.ID,
		Status: common.FriendApplyStatusDel,
	})
	if err != nil {
		return nil, err
	}
	return &types.Empty{}, nil
}
